package com.wavehi.reactive8;

import java.util.Observable;
import java.util.Observer;

/**
 * @Author WaveHi
 * @Date 26/10/2021 下午 2:40
 * @Version 1.0
 * @Contact HJBWaveHi@163.com
 * @Description Demonstrate the use of observer.
 */
public class ObserverDemo01 extends Observable {

    public static void main(String[] args) {
        //Provide the observed object
        ObserverDemo01 observerDemo01 = new ObserverDemo01();
        //Add the observer to observed object..
        observerDemo01.addObserver((o, arg)-> {
            System.out.println("Wow!");
        });
        //Test
        //Indicate that object has changed.
        observerDemo01.setChanged();
        //Notify the observers.
        observerDemo01.notifyObservers();
    }

}
